
SET( TestI2CSlave_SOURCES TestI2CSlave.cpp ) 
SET( TestOpen_SOURCES TestOpen.cpp ) 
      
message("build type:" ${CMAKE_BUILD_TYPE})    

if(WIN32)
      include_directories ("../Dependencies/opencv340/include") 
      
      if (CMAKE_CL_64)
            link_directories("../Dependencies/opencv340/x64/lib")
      else ()
            link_directories("../Dependencies/opencv340/x86/lib")
      endif ()

      if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
            set(OpenCV_LIBS "opencv_world340d")
      else()
            set(OpenCV_LIBS "opencv_world340")
      endif()
                  
else(UNIX)
      find_package( OpenCV REQUIRED )
      if( OpenCV_FOUND )
            list( APPEND ThirdParty_LIBS ${OpenCV_LIBS} )
            include_directories( ${OpenCV_INCLUDE_DIRS} )
      endif( OpenCV_FOUND )
            include_directories( ${OPENCV_INCLUDE_DIR} ) 
endif(WIN32)

source_group("" FILES ${TestI2CSlave_SOURCES})
source_group("" FILES ${TestOpen_SOURCES})

include_directories ("../MoveSenseCamera")

add_executable (TestI2CSlave ${TestI2CSlave_SOURCES})
add_executable (TestOpen ${TestOpen_SOURCES})

target_link_libraries(TestI2CSlave MoveSenseCamera  ${OpenCV_LIBS} ${LIBUSB_LIBS})
target_link_libraries(TestOpen MoveSenseCamera  ${OpenCV_LIBS} ${LIBUSB_LIBS})

set_property(TARGET TestI2CSlave PROPERTY FOLDER "Tests")
set_property(TARGET TestOpen PROPERTY FOLDER "Tests")

set_target_properties(TestI2CSlave PROPERTIES
                      RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set_target_properties(TestOpen PROPERTIES
                      RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

if(WIN32)
      if (CMAKE_CL_64)
            add_custom_command(
                  TARGET TestI2CSlave
                  POST_BUILD
                  COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Dependencies/opencv340/x64/bin ${CMAKE_CURRENT_BINARY_DIR}
                  DEPENDS TestI2CSlave
            )
      else ()
            add_custom_command(
                  TARGET TestI2CSlave
                  POST_BUILD
                  COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Dependencies/opencv340/x86/bin ${CMAKE_CURRENT_BINARY_DIR}
                  DEPENDS TestI2CSlave
            )
      endif ()
      add_custom_command(
            TARGET TestI2CSlave
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ConfigFiles ${CMAKE_CURRENT_BINARY_DIR}/ConfigFiles
            DEPENDS TestI2CSlave
      )
      
      if (CMAKE_CL_64)
            add_custom_command(
                  TARGET TestOpen
                  POST_BUILD
                  COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Dependencies/opencv340/x64/bin ${CMAKE_CURRENT_BINARY_DIR}
                  DEPENDS TestOpen
            )
      else ()
            add_custom_command(
                  TARGET TestOpen
                  POST_BUILD
                  COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Dependencies/opencv340/x86/bin ${CMAKE_CURRENT_BINARY_DIR}
                  DEPENDS TestOpen
            )
      endif ()
      add_custom_command(
            TARGET TestOpen
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ConfigFiles ${CMAKE_CURRENT_BINARY_DIR}/ConfigFiles
            DEPENDS TestOpen
      )
else(UNIX)
      add_custom_command(
            TARGET TestI2CSlave
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ConfigFiles ${PROJECT_BINARY_DIR}/bin/ConfigFiles
            DEPENDS TestI2CSlave
      )
      
      add_custom_command(
            TARGET TestOpen
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ConfigFiles ${PROJECT_BINARY_DIR}/bin/ConfigFiles
            DEPENDS TestOpen
      )
endif(WIN32)
